package com.zensation.ticklemepanda.util;

import com.zensation.ticklemepanda.R;

import android.content.Context;

public class SoundManager {
	private static Sound giggleSound = null;
	private static Sound crySound = null;
	private static Sound sleepSound = null;
	private static Sound wakeUpSound = null;
	private static Sound splashScreen = null;
	private static Sound endGameScreen = null;
	private static Sound snoozeSound = null;
	
	/* giggle Sound */
	public static Sound getGiggleSound(Context context) {
		if (giggleSound == null) {
			giggleSound = new Sound(context, R.raw.laugh4);
		}
		return giggleSound;
	}

	/* Cry Sound */
	public static Sound getCrySound(Context context) {
		if (crySound == null) {
			crySound = new Sound(context, R.raw.cry4);
		}
		return crySound;
	}
	/*
	 * snooze sound
	 */
	public static Sound getSnoozeSound(Context context){
		if(snoozeSound == null){
			snoozeSound = new Sound(context, R.raw.snore4);
		}
		return snoozeSound;
	}
	/* sleep sound */
	public static Sound getSleepSound(Context context) {
		if (sleepSound == null) {
			sleepSound = new Sound(context, R.raw.chrap);
		}
		return sleepSound;
	}

	/* wake up sound */
	public static Sound getWakeUpSound(Context context) {
		if (wakeUpSound == null) {
			wakeUpSound = new Sound(context, R.raw.wakeup1);
		}
		return wakeUpSound;
	}

	/* splash screen sound */
	public static Sound getSplashScreenSound(Context context) {
		if (splashScreen == null) {
			splashScreen = new Sound(context, R.raw.splash);
		}
		return splashScreen;
	}

	/* end game sound */
	public static Sound getEndGameSound(Context context) {
		if (endGameScreen == null) {
			endGameScreen = new Sound(context, R.raw.chrap);
		}
		return endGameScreen;
	}

	/**
	 * stop all sound when win game or exit game
	 * 
	 * @param context
	 */
	public static void stopAll(Context context) {
		
		if (getCrySound(context).getIsPlaying())
			getCrySound(context).stop();
		
		if (getEndGameSound(context).getIsPlaying())
			getEndGameSound(context).stop();
		
		if (getGiggleSound(context).getIsPlaying())
			getGiggleSound(context).stop();
		
		if (getSleepSound(context).getIsPlaying())
			getSleepSound(context).stop();
		
		if (getSplashScreenSound(context).getIsPlaying())
			getSplashScreenSound(context).stop();
		
		if (getWakeUpSound(context).getIsPlaying())
			getWakeUpSound(context).stop();
	}

}
